package com.aqielife.demo.handler;

import org.springframework.stereotype.Component;
import org.springframework.web.reactive.socket.WebSocketHandler;
import org.springframework.web.reactive.socket.WebSocketSession;
import reactor.core.publisher.Mono;

/**
 * @author aqie
 * @date 2022/02/04 23:20
 * @desc
 */
@Component
public class EchoHandler implements WebSocketHandler {
  @Override
  public Mono<Void> handle(final WebSocketSession session) {
    return session.send(
    session.receive()
    .map(msg -> session.textMessage(
    "服务端返回：小明， -> " + msg.getPayloadAsText())));
  }
}
